//
//  ExamineViewController.m
//  OAProject
//
//  Created by yhj on 2017/2/22.
//  Copyright © 2017年 cdnunion. All rights reserved.
//

#import "ExamineViewController.h"
#import "ContractMainViewController.h"
#import "LeaveMainViewController.h"

static NSString *tableViewCellIdentifier=@"UITableViewCellIdentifier";
@interface ExamineViewController ()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic,strong)UITableView *examineMainTableView;

@end

@implementation ExamineViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self initTableView];

    self.title=@"审批";

}

-(void)initTableView
{
    // examineMainTableView
    _examineMainTableView=[[UITableView alloc]initWithFrame:CGRectMake(0,0,APPW,APPH) style:UITableViewStylePlain];
    _examineMainTableView.delegate=self;
    _examineMainTableView.dataSource=self;
    _examineMainTableView.backgroundColor=MAIN_BACK_COLOR;
    _examineMainTableView.tableFooterView=[UIView new];
    [self.view addSubview:_examineMainTableView];
    [_examineMainTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:tableViewCellIdentifier];
}


-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 5;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSArray *arrImage=@[@"contract",@"open",@"leave",@"pressMoney",@"freeMoney"];
    NSArray *arrTitle=@[@"合同",@"开通",@"请假",@"催款",@"报销"];

    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:tableViewCellIdentifier];
    cell.selectionStyle=UITableViewCellSelectionStyleNone;
    cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
    cell.textLabel.text=arrTitle[indexPath.row];
    cell.imageView.image=[UIImage imageNamed:arrImage[indexPath.row]];
    return cell;

}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return kmargin*6;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    if (indexPath.row==0)
    {
        // 合同
        ContractMainViewController *contractMainViewController=[ContractMainViewController new];
        contractMainViewController.hidesBottomBarWhenPushed=YES;
        [self.navigationController pushViewController:contractMainViewController animated:NO];
    }
    else if (indexPath.row==2)
    {
        // 请假
        LeaveMainViewController *leaveMainViewController=[LeaveMainViewController new];
        leaveMainViewController.hidesBottomBarWhenPushed=YES;
        [self.navigationController pushViewController:leaveMainViewController animated:NO];
    }
}
// 间隙置边
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{

    if ([tableView respondsToSelector:@selector(setSeparatorInset:)])
    {
        [tableView setSeparatorInset:UIEdgeInsetsZero];
    }

    if ([tableView respondsToSelector:@selector(setLayoutMargins:)])
    {
        [tableView setLayoutMargins:UIEdgeInsetsZero];
    }

    if ([cell respondsToSelector:@selector(setLayoutMargins:)])
    {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
}

@end
